package controller;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.GetPopularKeywordsDAO;
import dao.GetSearchKeywordsRecommendationDAO;

public class GetPopularKeywordsAction extends Action{

	@Override
	public String perform(HttpServletRequest request,
			HttpServletResponse response) {
		
		String add=request.getParameter("add");
		
		//case the first time come
		if(add==null||add.length()==0){
			return "getPopularKeywords.view";
		}
		
		//get user input information
		String category=request.getParameter("givenkeyword");
		
		//update to ebay
		if(category!=null){
			HashMap<String,String> data = GetPopularKeywordsDAO.getPopularKeywordsDAO(category);
			request.setAttribute("timestamp", data.get("Timestamp"));
			request.setAttribute("categoryID", data.get("CategoryID"));
			request.setAttribute("keywords", data.get("Keywords"));
		}
		
		return "getPopularKeywordsResult.view";
	}

}
